package com.ymatou.iapi.coupon.testcase;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.coupon.parameter.UserReceiveResultInfo;
import com.ymatou.iapi.coupon.parameter.UserReceiveResultList;
import com.ymatou.iapi.coupon.parameter.receiveCouponBean;
import com.ymatou.iapi.coupon.service.receiveCouponCall;
import com.ymatou.iapi.couponmanage.parameter.BatchInfo;
import com.ymatou.iapi.couponmanage.parameter.CreateBagBean;
import com.ymatou.iapi.couponmanage.parameter.CreateBean;
import com.ymatou.iapi.couponmanage.parameter.CreateCouponBean;
import com.ymatou.iapi.couponmanage.parameter.SellerCreateBatchBean;
import com.ymatou.iapi.couponmanage.parameter.executeTaskBean;
import com.ymatou.iapi.couponmanage.service.CreateBagCall;
import com.ymatou.iapi.couponmanage.service.CreateCall;
import com.ymatou.iapi.couponmanage.service.CreateCouponCall;
import com.ymatou.iapi.couponmanage.service.SellerCreateBatchCall;
import com.ymatou.iapi.couponmanage.service.executeTaskCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponServiceMCallServiceV2;
import com.ymttest.database.model.coupon;
import com.ymttest.database.model.couponbatch;
import com.ymttest.database.model.couponconversion;
import com.ymttest.database.model.couponconversioncode;
import com.ymttest.database.sqlwapper.couponWapper;
import com.ymttest.database.sqlwapper.couponbagWapper;
import com.ymttest.database.sqlwapper.couponbatchWapper;
import com.ymttest.database.sqlwapper.couponconversionWapper;
import com.ymttest.database.sqlwapper.couponconversioncodeWapper;
import com.ymttest.database.sqlwapper.couponsendsubtaskWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
/**
*领取优惠券
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_receiveCoupon{
	private static receiveCouponBean bean;
	private static receiveCouponCall call;
	private couponbatchWapper couponbatchWapper=new couponbatchWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("领取优惠券");
	}

	@Before
	public void caseUp() {
		bean=new receiveCouponBean();
		call=new receiveCouponCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_001() {
		Logger.start(true,"领取优惠券-平台券-单张券-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setIdentityKey(TestDataManager.getRandomUUID().toString());
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_002() {
		Logger.start(true,"领取优惠券-平台券-单张券-一个用户领取多张-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setPerUserReceiveMaxCount(2);
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();	
			verifyReturn(batchIdlist,receiveCountlist,1);	
			
			List<Integer> receiveCountlist1 = new ArrayList<>();
			List<Integer> batchIdlist1 = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist1.add(batch.getBatchId());
				receiveCountlist1.add(batch.getReceivedCount());
			}
			call.callService();
			verifyReturn(batchIdlist1,receiveCountlist1,2);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_003() {
		Logger.start(true,"领取优惠券-平台券-多张券-一个用户领取多张-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setPerUserReceiveMaxCount(2);
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
			CreateCouponCall createCouponCall1 = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
			
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			batchCodes.add(createCouponCall1.getBatchCode());
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();	
			verifyReturn(batchIdlist,receiveCountlist,1);	
			
			List<Integer> receiveCountlist1 = new ArrayList<>();
			List<Integer> batchIdlist1 = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist1.add(batch.getBatchId());
				receiveCountlist1.add(batch.getReceivedCount());
			}
			call.callService();	
			verifyReturn(batchIdlist1,receiveCountlist1,2);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_004() {
		Logger.start(true,"领取优惠券-商家券-单张券-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_005() {
		Logger.start(true,"领取优惠券-商家券-单张券-一个用户领取多张-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean.setReceiveNumPerUser(2);
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}

			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();	
			verifyReturn(batchIdlist,receiveCountlist,1);	
			
			List<Integer> receiveCountlist1 = new ArrayList<>();
			List<Integer> batchIdlist1 = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist1.add(batch.getBatchId());
				receiveCountlist1.add(batch.getReceivedCount());
			}
			call.callService();
			verifyReturn(batchIdlist1,receiveCountlist1,2);				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_006() {
		Logger.start(true,"领取优惠券-商家券-多张券-一个用户领取多张-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean.setReceiveNumPerUser(2);
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
			SellerCreateBatchCall sellerCreateBatchCall2 = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());
			batchCodes.add(sellerCreateBatchCall2.getBatchCode());
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();	
			verifyReturn(batchIdlist,receiveCountlist,1);	
			
			List<Integer> receiveCountlist1 = new ArrayList<>();
			List<Integer> batchIdlist1 = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist1.add(batch.getBatchId());
				receiveCountlist1.add(batch.getReceivedCount());
			}
			call.callService();
			verifyReturn(batchIdlist1,receiveCountlist1,2);					
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_receiveCoupon_007() {
		Logger.start(true,"领取优惠券-平台券-userType=0未知-返回成功");
		try {
			//平台
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_receiveCoupon_008() {
		Logger.start(true,"领取优惠券-商家券-userType=0未知-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());		
			
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_receiveCoupon_009() {
		Logger.start(true,"领取优惠券-套券-userType=0未知-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createBagCall.getbagCode());		

			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().getCouponBatchByBagCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_receiveCoupon_010() {
		Logger.start(true,"领取优惠券-平台券-userType=1新用户-返回成功");
		try {
			//平台
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(1);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_receiveCoupon_011() {
		Logger.start(true,"领取优惠券-商家券-userType=1新用户-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());		
			
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(1);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_receiveCoupon_012() {
		Logger.start(true,"领取优惠券-套券-userType=1新用户-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createBagCall.getbagCode());		

			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().getCouponBatchByBagCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(1);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_receiveCoupon_013() {
		Logger.start(true,"领取优惠券-平台券-userType=2老用户-返回成功");
		try {
			//平台
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(2);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_receiveCoupon_014() {
		Logger.start(true,"领取优惠券-商家券-userType=2老用户-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());		
			
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(2);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_receiveCoupon_015() {
		Logger.start(true,"领取优惠券-套券-userType=2老用户-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createBagCall.getbagCode());		

			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().getCouponBatchByBagCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(2);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_receiveCoupon_016() {
		Logger.start(true,"领取优惠券-平台券+商家券-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();
			// 平台优惠券-链接
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();		
			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
			// 设置batchcode
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(couponCallService.SellerCreateBatch(couponBatchBean).getBatchCode());	
			batchCodes.add(couponCallService.createPlatformCoupon(createcouponBean).getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
		 
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getMessage().contains("不允许既领取平台优惠券又领取买手优惠券"), "验证返回Message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	@Ignore
	public void Ts_receiveCoupon_017() {
		Logger.start(true,"领取优惠券-套券-一个批次-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createBagCall.getbagCode());		

			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().getCouponBatchByBagCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(1);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_receiveCoupon_018() {
		Logger.start(true,"领取优惠券-套券-多个批次-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = setMoreCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createBagCall.getbagCode());		

			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().getCouponBatchByBagCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	@Ignore
	public void Ts_receiveCoupon_019() {
		//套券业务已取消
		Logger.start(true,"领取优惠券-平台券-套券兑换优惠券-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setAcquireCouponMethod(2);
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			CreateBean createBean=CouponServiceMCallServiceV2.setDefaultCustomCreateBean(batchCodes);
			CreateCall createCall=CouponServiceMCallServiceV2.create(createBean);
						
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().getCouponBatchByBagCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_receiveCoupon_021() {
		Logger.start(true,"领取优惠券-平台券-不在领取时间-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());
			couponbatch beforBatch = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode()).get(0);
			Date dNow = new Date(); // 当前时间
	        Date dBefore = new Date();
	        Date dAfter = new Date();

	        Calendar calendar1 = Calendar.getInstance(); // 得到日历
	        calendar1.setTime(dNow);// 把当前时间赋给日历
	        calendar1.add(Calendar.DAY_OF_MONTH, -10); // 设置为前一天
	        dBefore = calendar1.getTime(); // 得到前一天的时间

	        Calendar calendar2 = Calendar.getInstance(); // 得到日历
	        calendar2.setTime(dNow);// 把当前时间赋给日历
	        calendar2.add(Calendar.DAY_OF_MONTH, -1); // 设置为后十天
	        dAfter = calendar2.getTime(); // 得到前一天的时间
	        new couponbatchWapper().setAcquireStartTime(beforBatch.getBatchCode(), dBefore);
	    	new couponbatchWapper().setAcquireEndTime(beforBatch.getBatchCode(), dAfter);

	    	List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getDescription().contains("超出领取结束时间"), "验证返回Message");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_receiveCoupon_022() {
		Logger.start(true,"领取优惠券-商家券-不在领取时间-返回成功，商家不限制过期时间");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());
			couponbatch beforBatch = new couponbatchWapper().selectBybatchCode(sellerCreateBatchCall.getBatchCode()).get(0);
			Date dNow = new Date(); // 当前时间
	        Date dBefore = new Date();
	        Date dAfter = new Date();

	        Calendar calendar1 = Calendar.getInstance(); // 得到日历
	        calendar1.setTime(dNow);// 把当前时间赋给日历
	        calendar1.add(Calendar.DAY_OF_MONTH, -10); // 设置为前一天
	        dBefore = calendar1.getTime(); // 得到前一天的时间

	        Calendar calendar2 = Calendar.getInstance(); // 得到日历
	        calendar2.setTime(dNow);// 把当前时间赋给日历
	        calendar2.add(Calendar.DAY_OF_MONTH, -1); // 设置为后十天
	        dAfter = calendar2.getTime(); // 得到前一天的时间
	        new couponbatchWapper().setAcquireStartTime(beforBatch.getBatchCode(), dBefore);
	    	new couponbatchWapper().setAcquireEndTime(beforBatch.getBatchCode(), dAfter);

	    	List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getDescription().contains("超出领取结束时间"), "验证返回Message");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_023() {
		Logger.start(true,"领取优惠券-套券-不在领取时间-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createBagCall.getbagCode());		
			
			couponbatch beforBatch = new couponbatchWapper().getCouponBatchByBagCode(createBagCall.getbagCode()).get(0);
			Date dNow = new Date(); // 当前时间
	        Date dBefore = new Date();
	        Date dAfter = new Date();

	        Calendar calendar1 = Calendar.getInstance(); // 得到日历
	        calendar1.setTime(dNow);// 把当前时间赋给日历
	        calendar1.add(Calendar.DAY_OF_MONTH, -10); // 设置为前一天
	        dBefore = calendar1.getTime(); // 得到前一天的时间

	        Calendar calendar2 = Calendar.getInstance(); // 得到日历
	        calendar2.setTime(dNow);// 把当前时间赋给日历
	        calendar2.add(Calendar.DAY_OF_MONTH, -1); // 设置为后十天
	        dAfter = calendar2.getTime(); // 得到前一天的时间
	        new couponbatchWapper().setAcquireStartTime(beforBatch.getBatchCode(), dBefore);
	    	new couponbatchWapper().setAcquireEndTime(beforBatch.getBatchCode(), dAfter);
	    	
	        new couponbagWapper().setAcquireStartTime(createBagCall.getbagCode(), dBefore);
	    	new couponbagWapper().setAcquireEndTime(createBagCall.getbagCode(), dAfter);

	    	List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().getCouponBatchByBagCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getDescription().contains("超出领取结束时间"), "验证返回Message");				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_receiveCoupon_024() {
		Logger.start(true,"领取优惠券-平台券-领取方式是兑换-返回失败(批次不能用于领取)");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setAcquireCouponMethod(2);
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getMessage().contains("批次仅允许兑换，不允许直接领取"), "验证返回Message");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	@Ignore
	public void Ts_receiveCoupon_025() {
		Logger.start(true,"领取优惠券-商家券-领取方式是兑换-返回失败(批次不能用于领取)");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean.setCouponType((byte)2);
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());	
	
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getMessage().contains("批次仅允许兑换，不允许直接领取"), "验证返回Message");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_receiveCoupon_026() {
		Logger.start(true,"领取优惠券-套券-领取方式是兑换-返回失败(批次不能用于领取)");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			createBagBean.setAcquireMethod(2);
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createBagCall.getbagCode());		
			
	
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getDescription().contains("批次不能用于领取"), "验证返回Description");	
			Logger.verifyEquals(true, call.getMessage().contains("操作成功！"), "验证返回Message");
			Logger.verifyEquals("3", call.getResult(), "验证返回Result");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_receiveCoupon_027() {
		Logger.start(true,"领取优惠券-平台券-批次不存在-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode()+"11");	
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getMessage().contains("批次不存在"), "验证返回Description");	
//			Logger.verifyEquals(true, call.getMessage().contains("操作成功！"), "验证返回Message");
//			Logger.verifyEquals("3", call.getResult(), "验证返回Result");				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_receiveCoupon_028() {
		Logger.start(true,"领取优惠券-商家券-批次不存在-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode()+"111");	
	
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getMessage().contains("批次不存在"), "验证返回Description");	
//			Logger.verifyEquals(true, call.getMessage().contains("操作成功！"), "验证返回Message");
//			Logger.verifyEquals("3", call.getResult(), "验证返回Result");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_receiveCoupon_029() {
		Logger.start(true,"领取优惠券-套券-批次不存在-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createBagCall.getbagCode()+"11");		
			
	
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getDescription().contains("批次不存在"), "验证返回Description");	
//			Logger.verifyEquals(true, call.getMessage().contains("操作成功！"), "验证返回Message");
//			Logger.verifyEquals("3", call.getResult(), "验证返回Result");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_receiveCoupon_030() {
		Logger.start(true,"领取优惠券-平台券-已领用-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			call.callService();		
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getDescription().contains("用户已领取过"), "验证返回Description");
//			Logger.verifyEquals(true, call.getMessage().contains("操作成功！"), "验证返回Message");
//			Logger.verifyEquals("2", call.getResult(), "验证返回Result");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_receiveCoupon_031() {
		Logger.start(true,"领取优惠券-商家券-已领用-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());	
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			call.callService();		
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getDescription().contains("用户已领取过"), "验证返回Description");
//			Logger.verifyEquals(true, call.getMessage().contains("操作成功！"), "验证返回Message");
//			Logger.verifyEquals("2", call.getResult(), "验证返回Result");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_receiveCoupon_032() {
		Logger.start(true,"领取优惠券-套券-已领用-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createBagCall.getbagCode());		
			
	
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			call.callService();	
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getDescription().contains("用户超出领取数"), "验证返回Description");
			Logger.verifyEquals(true, call.getMessage().contains("操作成功！"), "验证返回Message");
			Logger.verifyEquals("2", call.getResult(), "验证返回Result");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	@Ignore
	public void Ts_receiveCoupon_033() {
		Logger.start(true,"领取优惠券-userId为空-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
		//	bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getDescription().contains("批次仅允许兑换，不允许直接领取"), "验证返回Message");
			Logger.verifyEquals("2", call.getResult(), "验证返回Result");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_receiveCoupon_036() {
		Logger.start(true,"领取优惠券-batchCodes为空-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
            List<String> batchCodes = new ArrayList<>();
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("1", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getErrorMessage().contains("batchCodes must not null"), "验证返回Description");	
			Logger.verifyEquals(true, call.getMessage().contains("batchCodes must not null"), "验证返回Message");	
			Logger.verifyEquals("0", call.getResult(), "验证返回Result");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_0040() {
		Logger.start(true,"领取优惠券-多个平台券-一个identityKey领取1次-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
			
			CreateCouponBean createcouponBean2 = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall2= CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean2);	
			
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());
			batchCodes.add(createCouponCall2.getBatchCode());
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			String uid=TestDataManager.getRandomUUID().toString();
			//领1次
			bean.setIdentityKey(uid);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();	
			
			verifyReturn(batchIdlist,receiveCountlist,1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_0037() {
		Logger.start(true,"领取优惠券-平台券-一个identityKey领取2次-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());
			
			CreateCouponBean createcouponBean2 = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall2= CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean2);	
			
			List<String> batchCodes2 = new ArrayList<>();
			batchCodes2.add(createCouponCall2.getBatchCode());
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			String uid=TestDataManager.getRandomUUID().toString();
			//领1次
			bean.setIdentityKey(uid);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();	
			//领2次
			bean.setIdentityKey(uid);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes2);
			call.callService();	
			
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("result"), "验证返回result");
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("failReason"), "验证返回failReason");
			Logger.verifyEquals("用户已领取过", new JSONObject(call.getData()).getString("description"), "验证返回description");
			Logger.verifyEquals("操作成功！", call.getMessage(), "验证返回Message");
			//verifyReturn(batchIdlist,receiveCountlist,1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_0038() {
		Logger.start(true,"领取优惠券-商家券-一个identityKey领取2次-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean.setReceiveNumPerUser(2);
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());	
			
			SellerCreateBatchCall sellerCreateBatchCall2 = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
            List<String> batchCodes2 = new ArrayList<>();
			batchCodes2.add(sellerCreateBatchCall2.getBatchCode());	

			String uid=TestDataManager.getRandomUUID().toString();
			//领1次
			bean.setIdentityKey(uid);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();	
			//领2次
			bean.setIdentityKey(uid);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes2);
			call.callService();	
			
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("result"), "验证返回result");
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("failReason"), "验证返回failReason");
			Logger.verifyEquals("用户已领取过", new JSONObject(call.getData()).getString("description"), "验证返回description");
			Logger.verifyEquals("操作成功！", call.getMessage(), "验证返回Message");
			//verifyReturn(batchIdlist,receiveCountlist,1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Ts_receiveCoupon_0039() {
		//套券业务已取消
		Logger.start(true,"领取优惠券-套券券-一个identityKey领取2次-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createBagCall.getbagCode());	
			
			
			CreateBagCall createBagCall2 = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			List<String> batchCodes2 = new ArrayList<>();
			batchCodes2.add(createBagCall2.getbagCode());	
			

			String uid=TestDataManager.getRandomUUID().toString();
			//领1次
			bean.setIdentityKey(uid);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();	
			//领2次
			bean.setIdentityKey(uid);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes2);
			call.callService();	
			
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("failReason"), "验证返回failReason");
			Logger.verifyEquals("用户已领取过", new JSONObject(call.getData()).getString("description"), "验证返回description");
			Logger.verifyEquals("操作成功！", call.getMessage(), "验证返回Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Ts_receiveCoupon_0041() {
		//套券业务取消
		Logger.start(true,"领取优惠券-套券-一个identityKey领取2次-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			createBagBean.setReceiveTimesPerUser(2);
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createBagCall.getbagCode());	
			
			
			String uid=TestDataManager.getRandomUUID().toString();
			//领1次
			bean.setIdentityKey(uid);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();
			call.callService();
			
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("failReason"), "验证返回failReason");
			Logger.verifyEquals("用户已领取过", new JSONObject(call.getData()).getString("description"), "验证返回description");
			Logger.verifyEquals("操作成功！", call.getMessage(), "验证返回Message");
			//verifyReturn(batchIdlist,receiveCountlist,1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_0042() {
		Logger.start(true,"领取优惠券-平台券-一个identityKey领取2次-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}	
			
			
			String uid=TestDataManager.getRandomUUID().toString();
			//领1次
			bean.setIdentityKey(uid);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();
			call.callService();
			
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("failReason"), "验证返回failReason");
			Logger.verifyEquals("用户已领取过", new JSONObject(call.getData()).getString("description"), "验证返回description");
			Logger.verifyEquals("操作成功！", call.getMessage(), "验证返回Message");
			//verifyReturn(batchIdlist,receiveCountlist,1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_0043() {
		Logger.start(true,"领取优惠券-商家券-一个identityKey领取2次-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}	
			
			
			String uid=TestDataManager.getRandomUUID().toString();
			//领1次
			bean.setIdentityKey(uid);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();
			call.callService();
			
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("failReason"), "验证返回failReason");
			Logger.verifyEquals("用户已领取过", new JSONObject(call.getData()).getString("description"), "验证返回description");
			Logger.verifyEquals("操作成功！", call.getMessage(), "验证返回Message");
			//verifyReturn(batchIdlist,receiveCountlist,1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Ts_receiveCoupon_0044() {
		//套券业务取消
		Logger.start(true,"领取优惠券-套券2个不同的identityKey领取各领一次-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateBagBean createBagBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBagBeanForRecieve();
			createBagBean.setReceiveTimesPerUser(2);
			CreateBagCall createBagCall = CouponServiceMCallServiceV2.createPlatformCouponBag(createBagBean);
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createBagCall.getbagCode());	
			
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			couponbatch batch =null;
			for (String batchCode:batchCodes) {
				if(batchCode.contains("B"))
					batch=new couponbatchWapper().getCouponBatchByBagCode(batchCode).get(0);
				else
				    batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			String uid=TestDataManager.getRandomUUID().toString();
			//领1次
			bean.setIdentityKey(uid);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();
			//领2次
			String uid2=TestDataManager.getRandomUUID().toString();
			bean.setIdentityKey(uid2);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);
			call.callService();
			
			verifyReturn(batchIdlist,receiveCountlist,2);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_0045() {
		Logger.start(true,"领取优惠券-平台券-一个批次，2个不同的identityKey领取各领一次-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setPerUserReceiveMaxCount(2);
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch   batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			String uid=TestDataManager.getRandomUUID().toString();
			//领1次
			bean.setIdentityKey(uid);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();
			verifyReturn(batchIdlist,receiveCountlist,1);
			
			//领2次
			String uid2=TestDataManager.getRandomUUID().toString();
			bean.setIdentityKey(uid2);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);
			call.callService();
			
			receiveCountlist = new ArrayList<>();
			batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch   batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
				receiveCountlist.add(batch.getReceivedCount());
			}
			verifyReturn(batchIdlist,receiveCountlist,2);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_0046() {
		Logger.start(true,"领取优惠券-商家券-一个批次，2个不同的identityKey领取各领一次-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean.setReceiveNumPerUser(2);
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());	
			
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch   batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			String uid=TestDataManager.getRandomUUID().toString();
			//领1次
			bean.setIdentityKey(uid);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();
			verifyReturn(batchIdlist,receiveCountlist,1);
			
			
			receiveCountlist = new ArrayList<>();
			batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch   batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
				receiveCountlist.add(batch.getReceivedCount());
			}
			//领2次
			String uid2=TestDataManager.getRandomUUID().toString();
			bean.setIdentityKey(uid2);
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);
			call.callService();

			
			verifyReturn(batchIdlist,receiveCountlist,2);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_047_1() {
		Logger.start(true,"领取优惠券-商家券-单张券-返回成功-分销");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
			//分销
			couponbatchWapper.setPlatformSource(1, sellerCreateBatchCall.getBatchCode());
			
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_047_2() {
		Logger.start(true,"领取优惠券-商家券-单张券-一个用户领取多张-返回成功-分销");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean.setReceiveNumPerUser(2);
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
			//分销
			couponbatchWapper.setPlatformSource(1, sellerCreateBatchCall.getBatchCode());
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}

			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();	
			verifyReturn(batchIdlist,receiveCountlist,1);	
			
			List<Integer> receiveCountlist1 = new ArrayList<>();
			List<Integer> batchIdlist1 = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist1.add(batch.getBatchId());
				receiveCountlist1.add(batch.getReceivedCount());
			}
			call.callService();
			verifyReturn(batchIdlist1,receiveCountlist1,2);				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_047_3() {
		Logger.start(true,"领取优惠券-商家券-多张券-一个用户领取多张-返回成功-分销");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean.setReceiveNumPerUser(2);
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
			SellerCreateBatchCall sellerCreateBatchCall2 = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());
			batchCodes.add(sellerCreateBatchCall2.getBatchCode());
			
			//分销
			couponbatchWapper.setPlatformSource(1, sellerCreateBatchCall.getBatchCode());
			couponbatchWapper.setPlatformSource(1, sellerCreateBatchCall2.getBatchCode());
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();	
			verifyReturn(batchIdlist,receiveCountlist,1);	
			
			List<Integer> receiveCountlist1 = new ArrayList<>();
			List<Integer> batchIdlist1 = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist1.add(batch.getBatchId());
				receiveCountlist1.add(batch.getReceivedCount());
			}
			call.callService();
			verifyReturn(batchIdlist1,receiveCountlist1,2);					
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_048() {
		Logger.start(true,"领取优惠券-平台券-单张券-相对时间是小时-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setEffectiveType(1);
			createcouponBean.setEffectiveTimeType(1);
			createcouponBean.setEffectiveDays(2);
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setIdentityKey(TestDataManager.getRandomUUID().toString());
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_049() {
		Logger.start(true,"领取优惠券-商家券-单张券-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean.setCouponType((byte)4);
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Ts_receiveCoupon_050() {
		Logger.start(true,"领取优惠券-平台券+商家券-平台券相对时间是小时，商家券类型是仅直播类型使用-返回失败");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();
			// 平台优惠券-链接
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setEffectiveType(1);
			createcouponBean.setEffectiveTimeType(1);
			createcouponBean.setEffectiveDays(2);
			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
			couponBatchBean.setCouponType((byte)4);
			// 设置batchcode
			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(couponCallService.SellerCreateBatch(couponBatchBean).getBatchCode());	
			batchCodes.add(couponCallService.createPlatformCoupon(createcouponBean).getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();		
		 
			Logger.verifyEquals("2", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals(true, call.getMessage().contains("不允许既领取平台优惠券又领取买手优惠券"), "验证返回Message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_051() {
		Logger.start(true,"领取优惠券-平台券-多张券-一个用户领取多张-部分相对时间是小时-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setPerUserReceiveMaxCount(2);
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
			createcouponBean.setEffectiveType(1);
			createcouponBean.setEffectiveTimeType(1);
			createcouponBean.setEffectiveDays(2);
			CreateCouponCall createCouponCall1 = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
			
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			batchCodes.add(createCouponCall1.getBatchCode());
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();	
			verifyReturn(batchIdlist,receiveCountlist,1);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_052() {
		Logger.start(true,"领取优惠券-商家券-多张券-一个用户领取多张-部分类型是仅直播时使用-返回成功");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellerCreateBatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean.setReceiveNumPerUser(2);
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
			sellerCreateBatchBean.setCouponType((byte)4);
			SellerCreateBatchCall sellerCreateBatchCall2 = CouponServiceMCallServiceV2.SellerCreateBatch(sellerCreateBatchBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(sellerCreateBatchCall.getBatchCode());
			batchCodes.add(sellerCreateBatchCall2.getBatchCode());
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);

			call.setData(bean);
			call.callService();	
			verifyReturn(batchIdlist,receiveCountlist,1);	
			
			List<Integer> receiveCountlist1 = new ArrayList<>();
			List<Integer> batchIdlist1 = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist1.add(batch.getBatchId());
				receiveCountlist1.add(batch.getReceivedCount());
			}
			call.callService();
			verifyReturn(batchIdlist1,receiveCountlist1,2);					
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_053() {
		Logger.start(true,"领取优惠券-平台券-单张券-限优选会员-返回成功-JIRACONN-32748");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setuseConditionType(12);
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setIdentityKey(TestDataManager.getRandomUUID().toString());
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);
			bean.setmemberGrade(1);//会员等级, null不进行验证，0不是会员

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_054() {
		Logger.start(true,"领取优惠券-平台券-单张券-优选会员 + 指定商品-返回成功-JIRACONN-32748");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setuseConditionType(13);
		     List<String> list = new ArrayList<String>();
	            list.add("111");
	            list.add("222");
	         createcouponBean.setProductIds(list);
	            
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setIdentityKey(TestDataManager.getRandomUUID().toString());
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);
			bean.setmemberGrade(1);//会员等级, null不进行验证，0不是会员

			call.setData(bean);
			call.callService();		
			verifyReturn(batchIdlist,receiveCountlist,1);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_055() {
		Logger.start(false,"领取优惠券-平台券-单张券-优选会员 -用户不是会员（memberGrade=0）-返回失败-JIRACONN-32748");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setuseConditionType(12);
			
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setIdentityKey(TestDataManager.getRandomUUID().toString());
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);
			bean.setmemberGrade(0);//会员等级, null不进行验证，0不是会员

			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals("24", new JSONObject(call.getData()).getString("failReason"), "验证返回failReason");
			Logger.verifyEquals(true, new JSONObject(call.getData()).getString("description").contains("必须是会员才能领取"), "验证返回description");
			Logger.verifyEquals(true, new JSONArray(new JSONObject(call.getData()).getString("couponCodes")).length()==0, "验证返回couponCodes");
			Logger.verifyEquals("操作成功！", call.getMessage(), "验证返回Message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_056() {
		Logger.start(false,"领取优惠券-平台券-单张券-优选会员+商品 -用户不是会员（memberGrade=0）-返回失败-JIRACONN-32748");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setuseConditionType(13);
		    List<String> list = new ArrayList<String>();
            list.add("111");
            list.add("222");
	        createcouponBean.setProductIds(list);
	            
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setIdentityKey(TestDataManager.getRandomUUID().toString());
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);
			bean.setmemberGrade(0);//会员等级, null不进行验证，0不是会员

			call.setData(bean);
			call.callService();		
			Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
			Logger.verifyEquals("24", new JSONObject(call.getData()).getString("failReason"), "验证返回failReason");
			Logger.verifyEquals(true, new JSONObject(call.getData()).getString("description").contains("必须是会员才能领取"), "验证返回description");
			Logger.verifyEquals(true, new JSONArray(new JSONObject(call.getData()).getString("couponCodes")).length()==0, "验证返回couponCodes");
			Logger.verifyEquals("操作成功！", call.getMessage(), "验证返回Message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_057() {
		Logger.start(true,"领取优惠券-平台券-单张券-优选会员 -传入会员等级为空（memberGrade）-返回成功-JIRACONN-32748");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setuseConditionType(12);
			
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setIdentityKey(TestDataManager.getRandomUUID().toString());
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);
		//	bean.setmemberGrade(0);//会员等级, null不进行验证，0不是会员

			call.setData(bean);
			call.callService();		
			
			verifyReturn(batchIdlist,receiveCountlist,1);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_receiveCoupon_058() {
		Logger.start(true,"领取优惠券-平台券-单张券-优选会员+商品 -传入会员等级为空（memberGrade）-返回成功-JIRACONN-32748");
		try {
			int userId=Integer.parseInt(TestDataManager.getRandomNum(5));
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createcouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createcouponBean.setuseConditionType(13);
		    List<String> list = new ArrayList<String>();
            list.add("111");
            list.add("222");
	        createcouponBean.setProductIds(list);
	        
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createcouponBean);
            List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());	
			
			List<Integer> receiveCountlist = new ArrayList<>();
			List<Integer> batchIdlist = new ArrayList<>();
			for (String batchCode:batchCodes) {
				couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				batchIdlist.add(batch.getBatchId());
				receiveCountlist.add(batch.getReceivedCount());
			}
			
			bean.setIdentityKey(TestDataManager.getRandomUUID().toString());
			bean.setUserId(userId);
			bean.setUserType(0);
			bean.setBatchCodes(batchCodes);
		//	bean.setmemberGrade(0);//会员等级, null不进行验证，0不是会员

			call.setData(bean);
			call.callService();		
			
			verifyReturn(batchIdlist,receiveCountlist,1);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	private void verifyReturn(List<Integer> batchIdlist,List<Integer> receiveCountlist,int couponCount) throws JSONException, ClientProtocolException, IOException
	{		
		new CouponServiceMCallServiceV2().updatereceivedandusedcount();
		Logger.verifyEquals("0", new JSONObject(call.getData()).getString("errorCode"), "验证返回errorCode");
		Logger.verifyEquals("0", new JSONObject(call.getData()).getString("failReason"), "验证返回failReason");

		Logger.verifyEquals("操作成功！", call.getMessage(), "验证返回Message");
		
		Logger.verifyEquals("null", new JSONObject(call.getReturnData()).getString("exceptionId"), "验证返回exceptionId");
		Logger.verifyEquals("", new JSONObject(call.getReturnData()).getString("stackTrace"), "验证返回stackTrace");
		Logger.verifyEquals("0", call.getCode(), "验证返回StatusCode");
		Logger.verifyEquals("null", new JSONObject(call.getReturnData()).getString("sellerId"), "验证返回sellerId");

		for(int i=0;i<bean.getBatchCodes().size();i++)
		{
			String batchCode=bean.getBatchCodes().get(i);
			couponbatch couponBatch=null;
			
			if(batchCode.contains("B"))
			{
			   couponBatch = new couponbatchWapper().getCouponBatchByBagCode(batchCode).get(0);
			}
			else
			{
				couponBatch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
				coupon coupon=new couponWapper().selectByBatchId(couponBatch.getBatchId()).get(0);
				//更改，一个用户的剩余领取数量
				String str=bean.getBatchCodes().get(i)+bean.getUserId();
				Logger.verifyEquals(true,isContain(coupon.getCouponCode(),str), "验证coupon表中couponCode中含batchcode+userid字符串");
				Logger.verifyEquals(couponBatch.getPlatformSource(), coupon.getPlatformSource(),
						"验证数据库couponbatch表中的字段PlatformSource与coupon表字段PlatformSource一致");
				
				if(couponBatch.getEffectiveType()==1&&couponBatch.getEffectiveValidType()==0)
				{
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
					Date validStart = coupon.getValidStart();
					Calendar calendar1 = Calendar.getInstance(); // 得到日历
					calendar1.setTime(validStart);// 把当前时间赋给日历
					if(couponBatch.getEffectiveTimeType()==0)//天
					{
						calendar1.add(Calendar.DAY_OF_MONTH, couponBatch.getEffectiveDays()); // 设置为前一天
						Date validEnd = calendar1.getTime(); // 得到前一天的时间
						Logger.verifyEquals(sdf.format(validEnd).substring(0, 10)+" 23:59:59.000", sdf.format(coupon.getValidEnd()),
								"验证Coupon表ValidEnd");
					}
					else if(couponBatch.getEffectiveTimeType()==1)//小时
					{
						calendar1.add(Calendar.HOUR_OF_DAY, couponBatch.getEffectiveDays());
						Date validEnd = calendar1.getTime(); // 得到前一天的时间
						Logger.verifyEquals(sdf.format(validEnd), sdf.format(coupon.getValidEnd()), "验证Coupon表ValidEnd");
					}
				}
			}
			List<coupon> coupons = new couponWapper().selectByBatchIdAndUserId(couponBatch.getBatchId(), bean.getUserId());
        	Logger.verifyEquals(couponCount, coupons.size(), "验证返回coupon生成"+couponCount+"条记录");
		}
		for (int i = 0; i < batchIdlist.size(); i++) {
			couponbatch couponbatch = new couponbatchWapper().selectByPrimaryKey(batchIdlist.get(i));
//			Logger.verifyEquals(1, couponbatch.getReceivedCount() - receiveCountlist.get(i),
//					"验证返回couponbatch表BatchId=" + batchIdlist.get(i) + "的记录中ReceiveCount多了"+1);
			
 		Logger.verifyEquals(1, couponbatch.getReceivedCount() - receiveCountlist.get(i),
		    	"验证返回couponbatch表BatchId=" + batchIdlist.get(i) + "的记录中ReceiveCount多了"+1);
		}
//		for (String batchCode : bean.getBatchCodes()) {
//			couponbatch batch=null;
//			if(batchCode.contains("B"))
//				batch = new couponbatchWapper().getCouponBatchByBagCode(batchCode).get(0);
//				else
//			     batch = new couponbatchWapper().selectBybatchCode(batchCode).get(0);
//
//		}
	}
	
	private boolean isListEaqual(List<String> list1,List<String> list2)
	{
		for(String str:list1)
		{
			if(!list2.contains(str))
				return false;
		}
		
		for(String str:list2)
		{
			if(!list1.contains(str))
				return false;
		}
		
		return true;
	}
	
	private boolean isContain(String str,String charStr)
	{
		return str.contains(charStr);
	}
	
	private CreateBagBean setMoreCouponBagBeanForRecieve()
	{
		CreateBagBean CreateBagBean = new CreateBagBean();
		CreateBagBean.setName("自动化创建套券领取优惠券");
		CreateBagBean.setDescription("自动化测试创建套券领取优惠券描述");
		CreateBagBean.setOperatorId(222222);
		CreateBagBean.setApplyUser("自动化user111");
		CreateBagBean.setApplyMemo("自动化测试创建套券领取优惠券申请理由");
		CreateBagBean.setEffectiveType(0);
		CreateBagBean.setEffectiveValidType(0);
		CreateBagBean.setEffectiveDays(0);
		
		Date dNow = new Date(); // 当前时间
		Date dBefore = new Date();
		Date dAfter = new Date();

		Calendar calendar1 = Calendar.getInstance(); // 得到日历
		calendar1.setTime(dNow);// 把当前时间赋给日历
		calendar1.add(Calendar.DAY_OF_MONTH, -1); // 设置为前一天
		dBefore = calendar1.getTime(); // 得到前一天的时间

		Calendar calendar2 = Calendar.getInstance(); // 得到日历
		calendar2.setTime(dNow);// 把当前时间赋给日历
		calendar2.add(Calendar.DAY_OF_MONTH, 10); // 设置为后十天
		dAfter = calendar2.getTime(); // 得到前一天的时间

		CreateBagBean.setValidStart(dBefore);
		CreateBagBean.setValidEnd(dAfter);
		CreateBagBean.setAcquireStartTime(dBefore);
		CreateBagBean.setAcquireEndTime(dAfter);
		// 获取优惠券方式(1:领取(默认) 2:兑换)
		CreateBagBean.setAcquireMethod(1);
		CreateBagBean.setTotalNum(10);
		CreateBagBean.setReceiveTimesPerUser(1);
		CreateBagBean.setReceiveUserType(0);
		List<Integer> usePlatforms = new ArrayList<Integer>();
		/*
		 * usePlatforms.add(1); usePlatforms.add(2); usePlatforms.add(3);
		 */
		CreateBagBean.setUsePlatformIds(usePlatforms);
		CreateBagBean.setApplyDepartment(1);
		String impresetInvoiceId = EnvSetup.getData("ImpresetInvoiceId");
		CreateBagBean.setImpresetInvoiceId(impresetInvoiceId);
		
		List<BatchInfo> BatchInfos=new ArrayList<BatchInfo>();
		BatchInfo info=new BatchInfo();
		info.setCouponName("自动化创建套券优惠券名称-子套券");
		info.setCouponDes("自动化创建套券优惠券描述-子套券");
		info.setApplyMemo("自动化创建申请理由-子套券");
		info.setOrderMinAmount(new BigDecimal(2));
		info.setDeductionMaxAmount(new BigDecimal(1));
		List<String> productIds = new ArrayList<String>();
		info.setProductIds(productIds);
		List<Integer> SellerIds = new ArrayList<Integer>();
		info.setSellerIds(SellerIds);
		List<Integer> ActivityIds = new ArrayList<Integer>();
		info.setActivityIds(ActivityIds);
		List<Integer> Brands = new ArrayList<Integer>();
		info.setBrands(Brands);
		List<Integer> Countrys = new ArrayList<Integer>();
		info.setCountrys(Countrys);
		List<Integer> Categories = new ArrayList<Integer>();
		info.setCategories(Categories);
		info.setLimitPspProduct(false);
		BatchInfos.add(info);
		BatchInfos.add(info);
		CreateBagBean.setBatchInfos(BatchInfos);
		return CreateBagBean;
	}
}